# Maintainer:  Bartłomiej Piotrowski <bpiotrowski@archlinux.org>
# Contributor: Allan McRae <allan@archlinux.org>

pkgname=expect
pkgver=5.45.4
pkgrel=4
pkgdesc='A tool for automating interactive applications'
arch=(loong64 x86_64)
url='https://www.nist.gov/el/msid/expect.cfm'
license=(custom)
depends=(tcl)
source=(https://downloads.sourceforge.net/project/expect/Expect/$pkgver/expect${pkgver}.tar.gz
	expect-5.45-format-security.patch)
sha256sums=('49a7da83b0bdd9f46d04a04deec19c7767bb9a323e40c4781f89caf760b92c34'
            'b141e1a18186aaedb48ad503f34848413819f7a55789d86d04f14e8ae4cacc56')

prepare() {
  cd expect${pkgver}
  patch -Np0 -i ${srcdir}/expect-5.45-format-security.patch
}

build() {
  cd expect${pkgver}
  ./configure --prefix=/usr --mandir=/usr/share/man
  make
}

check() {
  cd expect${pkgver}
  make test
}

package() {
  cd expect${pkgver}
  make DESTDIR="$pkgdir" install
  install -Dm644 README "$pkgdir/usr/share/licenses/$pkgname/README"

  # avoid file conflict with the more powerful mkpasswd from the whois package
  mv -v "$pkgdir"/usr/bin/mkpasswd{,-expect}
  mv -v "$pkgdir"/usr/share/man/man1/mkpasswd{,-expect}.1
}
